/******************************************************************************
 *
 * MotionViewer
 * Copyright (C) 2007 Sangyoon Lee, Electronic Visualization Laboratory, 
 * University of Illinois at Chicago
 *
 * This software is free software; you can redistribute it and/or modify it 
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either Version 2.1 of the License, or 
 * (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
 * License for more details.
 * 
 * You should have received a copy of the GNU Lesser Public License along
 * with this software; if not, write to the Free Software Foundation, Inc., 
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 * Questions or comments about MotionViewer should be directed to 
 * cavern@evl.uic.edu
 *
 *****************************************************************************/


#ifndef __VICONVISUALIZER_H__
#define __VICONVISUALIZER_H__

#pragma warning(disable:4267)	

#include <ogre.h>
using namespace Ogre;

class ViconMotionDataSet;

enum tagBODY_TYPE 
{
	BT_NONE					= 0,
	BT_BODY					= 1,
	BT_AXIS					= 2,
	BT_ALL					= 3,
};

// body data struct
typedef struct VICONBODY{
	SceneNode*		pNode;
	Entity*			pEnt;
	ManualObject*	pAxis;
} sVICONBODY;


class ViconVisualizer
{
public:

	ViconVisualizer(SceneManager* mgr, SceneNode* head);
	virtual ~ViconVisualizer();
	
	virtual void createScene(char* source);
	virtual void resetScene();
	virtual void update(float addedTime);
	virtual void rewind(void) {}
	
	void setDebug(bool debug=true);
	std::string getDebugBodyInfo();
	std::string getDebugMarkerInfo();

	void setMarkerVisible(bool vis = true);
	void toggleMarkerVisible() { setMarkerVisible(!m_bMarkerVisibility);}
	void setBodyVisible(bool vis = true);
	void setBodyDrawingTypes(tagBODY_TYPE type, bool value);
	void toggleBodyDrawingTypes(tagBODY_TYPE type);

	void setPosition(float x, float y, float z);
	void getPosition(float* pos);

	void setMarkerColor(float r, float g, float b, float a);
	void setBodyColor(float r, float g, float b, float a);
	const ColourValue& getMarkerColor();
	const ColourValue& getBodyColor();
	
	int  getNumBodies() { return m_vBodies.size();}
	int  getNumMarkers() { return m_vMarkerNodes.size();}

	ViconMotionDataSet* getDataSet() { return m_pDataSet;}
	
	std::string getSubjectName();
	std::string getSubjectFullPath();
	std::string getSubjectFileName();
	
	int getID() { return m_iUID;}

protected:
	
	int				m_iUID;
	int				m_iMarkers;
	int				m_iBodies;
	bool			m_bMarkerVisibility;
	bool			m_bBodyVisibility;
	
	ViconMotionDataSet*			m_pDataSet;

	std::vector< SceneNode* >	m_vMarkerNodes;
	std::vector< sVICONBODY* >	m_vBodies;

	// Ogre related
	SceneManager*	m_pSceneMgr;
	SceneNode*		m_pHeadNode;
	SceneNode*		m_pBaseNode;
	MaterialPtr		m_pMarkerMaterial;
	MaterialPtr		m_pBodyMaterial;

};

#endif